package com.gg.cart.controller;

import com.gg.cart.service.CartService;
import com.gg.cart.service.impl.CartServiceImpl;
import com.gg.entity.User;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "RemoveCartByCidServlet", value = "/cart/RemoveCartByCidServlet")
public class RemoveCartByCidServlet extends HttpServlet {
    /*依赖*/
    private CartService  cartService =  new CartServiceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        /*参数*/
        String cid =  request.getParameter("cid");
        /*调用cartService  删除业务*/
        cartService.removeCartByCid(cid);

        /*Session  user   uid */
        User  u = (User) request.getSession().getAttribute("user");
        String uid = u.getUid();
        System.out.println(uid+"-----");
        /*请求查询当前用户购物车条目Servlet即可！*/
        response.sendRedirect("/fruit/cart/GetCartsByUidServlet?uid="+uid);

    }


}
